/*
 * @Descripttion:
 * @version:
 * @Author: sueRimn
 * @Date: 2020-10-30 15:29:40
 * @LastEditors: sueRimn
 * @LastEditTime: 2020-11-11 16:17:36
 */
import request from '@/utils/request'
import store from '@/store/index'
const base = require('../../env/index')

// 夹带k_token
function addK_Token(data) {
    var token = {
        k_token: store.getters.k_token
    }
    Object.assign(data, token)
    return data
}

/**
 * 获取机构所有角色列表
 */
export function get_allInstitutionalRole(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/role/getrole',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 获取机构下所有权限
 */
export function get_allInstitutionalAuth(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/auth/getauth',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 查看改角色下的权限
 */
export function get_oneInstitutionalAuth(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/role/getauth',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 查看该老师下的权限
 */
export function get_teacherInstitutionalAuth(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/auth/getteacherauth',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 修改该老师下的权限
 */
export function save_teacherInstitutionalAuth(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/auth/setteacherauth',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 给角色赋权
 */
export function seve_InstitutionalAuth(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/role/authrole',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 新增角色
 */
export function add_institutionalRole(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/role/save',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 多级新增角色
 */
export function adds_institutionalRoles(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/role/saverole',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 删除角色
 */
export function del_institutionalRole(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/role/delete/' + data.id,
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 给用户赋值角色
 */
export function add_roletoteacher(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/role/roletoteacher',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}

/**
 * 给用户取消角色
 */
export function del_roletoteacher(data) {
    return request({
        url: base.permission_url + '/api/v1/admin/role/rolecancelteacher',
        method: 'POST',
        headers: {},
        data: addK_Token(data)
    })
}
